<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="../css/common.css?01_38" />
		<link rel="stylesheet" type="text/css" href="../css/templet.css?01_38" />
		<link rel="stylesheet" type="text/css" href="../fonts/font-awesome.min.css?01_38" />
		<link rel="stylesheet" type="text/css" href="../mui/css/mui.css?01_38" />

		<!--公共js-->
		<script type="text/javascript" src="../common/js/jquery.js?01_38"></script>
		
		<!--插件-->
		<script type="text/javascript" src="../common/js/vue.min.js?01_38"></script>
		<script type="text/javascript" src="../common/js/mui.min.js?01_38"></script>
		
		<script type="text/javascript" src="../common/js/fastclick.js?01_38"></script>
		<script type="text/javascript" src="../common/js/common.js?01_38"></script>
		<script type="text/javascript" src="../common/js/my_common.js?01_38"></script>
		<script type="text/javascript" src="../common/js/main.js?01_38"></script>
		<script type="text/javascript" src="../common/js/app.js?01_38"></script>
	</head>

	<body>
		<div class="wrap_body go_duty" id="app" v-cloak>

			<header class="bg-red9 fff f-20 pad-t-10 pad-b-10 pad-r-10 ">
				<div class="pa back pad-l-10" onclick="back();">
					<a></a>
				</div>
				<div class="center">{{b_lg[1245]}}</div>
			</header>

			<div class="mask bg-000 pa loading hide">
				<div class="pad-l-40 pad-r-40 pad-t-200">
					<div class="bg-fff wrap pr center ">
						<img src="../images/default_graph/animation.gif" />
					</div>
				</div>
			</div>
			<div class="content pad-l-15 pad-r-15 pad-t-20 center pad-t-65">
				<div>
					<div class="top fff pad-t-20 pad-b-15">
						<p>
							<img v-if=" shop_logo!='' " :src="oss+shop_logo" class="icon" />
							<img v-else :src="con_img" class="icon" onerror="lod(this)" />
						</p>
						<p class="f-20 f-b mag-t-15">{{shop_info.shop_name}}</p>
						<p class="f-15 pad-t-5 pad-l-5 pad-r-5">{{shop_info.shop_address}}</p>
					</div>

					<div class="bottom bg-fff">
						<div class=" pad-t-40 pad-b-45">
							<p class="f-16 red9">
								<span class="f-30 f-b">{{h}} </span><span>{{b_lg[1258]}}</span><span class="f-30 f-b"> {{m}} </span><span>{{b_lg[1259]}}</span>
							</p>
							<p class="pad-t-20"><span class="f-16">{{b_lg[1256]}}：</span><span class="f-20 f-b"> {{new Date(obj.time*1000).format("hh:mm:ss")}}</span></p>
							<p class="f-16 pad-t-10">
								<span>{{new Date(obj.time*1000).format("yyyy年MM月dd日")}} </span>
								<span> {{b_lg[1260].split(',')[new Date(obj.time*1000).getDay()]}}</span>
							</p>
							 <div class="pad-t-20" id="google_geo"></div>
						</div>
						<div>
							<div class="circle fl"></div>
							<div class="circle fr"></div>
						</div>
						<hr />
						<div v-if="is_open_scan_work == 1" class="mag-t-20 pad-b-20 page" @click="scan_work">
							<p class="go off"></p>
							<p class="red9 pad-t-10">{{b_lg[1387]}}</p>
						</div>
						<div v-else="is_open_scan_work == 0" class="mag-t-20 pad-b-20 page" @click="offwork">
							<p class="go off"></p>
							<p class="red9 pad-t-10">{{b_lg[1245]}}</p>
						</div>
					</div>
					<div class="page bank5 bg-fff col-sm-11 page_01"></div>
					<div class="page bank5 bg-fff col-sm-10 page_02"></div>
				</div>
			</div>
			<div class="bank40"></div>

		</div>
	</body>
	<script type="text/javascript">
		var app = null;
		// H5 plus事件处理
		function plusReady() {}
		if(window.plus) {
			plusReady();
		} else {
			document.addEventListener('plusready', plusReady, false);
		}

		// 关闭自身窗口
		function closeme() {
			var ws = plus.webview.currentWebview();
			var preUrl = plus.webview.currentWebview().opener();

			plus.webview.close(ws);
			plus.webview.close(preUrl);
		}

		function fun1() {
//          getLocation();
//			function getLocation() {
//				if(navigator.geolocation) {
//					navigator.geolocation.getCurrentPosition(showPosition, showError);
//				} else {
//					alert("浏览器不支持地理定位。");
//				}
//			}
//
//			function showError(error) {
//				switch(error.code) {
//					case error.PERMISSION_DENIED:
//						alert("定位失败,用户拒绝请求地理定位");
//						break;
//					case error.POSITION_UNAVAILABLE:
//						alert("定位失败,位置信息是不可用");
//						break;
//					case error.TIMEOUT:
//						alert("定位失败,请求获取用户位置超时");
//						break;
//					case error.UNKNOWN_ERROR:
//						alert("定位失败,定位系统失效");
//						break;
//				}
//			}
//
//			function showPosition(position) {
//				var lat = position.coords.latitude; //纬度 
//				var lag = position.coords.longitude; //经度 
//				alert('纬度:' + lat + ',经度:' + lag);
//			}
//
//			function showPosition(position) {
//				var latlon = position.coords.latitude + ',' + position.coords.longitude;
//
//				//google 
//				var url = 'http://maps.google.cn/maps/api/geocode/json?latlng=' + latlon + '&language=CN';
//				$.ajax({
//					type: "GET",
//					url: url,
//					beforeSend: function() {
//						$("#google_geo").html('正在定位...');
//					},
//					success: function(json) {
//						if(json.status == 'OK') {
//							var results = json.results;
//							$.each(results, function(index, array) {
//								if(index == 0) {
//									alert(JSON.stringify(array))
//									$("#google_geo").html(array['formatted_address']);
//								}
//							});
//						}
//					},
//					error: function(XMLHttpRequest, textStatus, errorThrown) {
//						$("#google_geo").html(latlon + "地址位置获取失败");
//					}
//				});
//			}

			app = new Vue({
				el: "#app",
				data: {
					obj: {},
					shop_info: {},
					shop_logo: "",
					username: "", //用户名
					weekend: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
					b_lg: global_lange, //语言包
					h: "",
					m: "",
					is_open_scan_work: "" //是否扫码上下班
				},
				created: function() {
					this.init();
				},
				methods: {
					init: function() {
						common_ajax(1, {}, "get_home", function(res) { //获取店铺信息
							if(res.status == 1) {
								console.log(res);
								app.obj = res.result;
								app.shop_logo = res.result.shop_info.shop_logo;
								app.is_open_scan_work = res.result.shop_info.is_open_scan_work;
								console.log(oss)
								console.log(app.obj.shop_info.shop_logo);
								app.h = parseInt((res.result.time - res.result.check_work.addtime) / 3600);
								console.log(app.h);
								app.m = parseInt((res.result.time - res.result.check_work.addtime) / 60 % 60);

								console.log(app.b_lg[1260].split(','));

								common_ajax(1, {}, "get_waiter_info", function(res) { //获取用户信息
									if(res.status == 1) {
										app.username = res.result.nickname;
									} else {
										mui.toast(res.msg);
									}
								})
							} else {
								mui.toast(res.msg);
							}

						})
					},
					gotoart: function(e) { //跳转地址
						clicked(e); //全局
					},
					//扫码上下班
					scan_work: function() {

						//跳转到扫码页
						setTimeout(function() {
							app.gotoart('../qrcode/qrscan.html?id=0&type=4&scan=1'); //上下班type=4
						}, 500)

					},
					offwork: function() {

						//提示框
						var btnArray2 = [app.b_lg[1049], app.b_lg[1008]];
						mui.confirm(app.b_lg[1265], app.b_lg[1050], btnArray2, function(ee) {
							if(ee.index == 1) {
								//确定
								common_ajax(1, {
									uuid: phone_uuid
								}, "put_work_sign_scan", function(res) {
									if(res.status == 1) {
										if(isAPP) {
											var preUrl = plus.webview.currentWebview().opener();

											preUrl.evalJS("refresh(1)");
										}
										setTimeout(function() {
											com_back();
										}, 500)
									}
								})

								//时间格式化
							} else {
								//取消
								app.init();
							}
						}, "div")
					}
				}
			})

		}
	</script>

</html>
